import java.util.LinkedList;
import java.util.List;

import edu.udo.cs.yale.Experiment;
import edu.udo.cs.yale.Yale;
import edu.udo.cs.yale.clustering.core.HierarchicalClusterModel;
import edu.udo.cs.yale.example.ExampleSet;
import edu.udo.cs.yale.operator.IOContainer;
import edu.udo.cs.yale.operator.Operator;
import edu.udo.cs.yale.tools.OperatorService;

/**
 * Illustrates how to use the word vector tool plugin and Yale from a Java application.
 * 
 * @author Michael Wurst
 * @version $Id: WVToolYaleExample.java,v 1.1 2006/07/05 13:45:00 ingomierswa Exp $
 *
 */
public class WVToolYaleExample {

    public static void main(String[] args) throws Exception {

        Yale.init();
        
        Experiment experiment = new Experiment();
        
        Operator wvtoolOperator = OperatorService.createOperator("WVTool");
        Operator clusterer = OperatorService.createOperator("UPGMAClustering");
        
        experiment.registerOperator("WVTool",wvtoolOperator);
        experiment.getRootOperator().addOperator(wvtoolOperator);
        
        List textList = new LinkedList();
        
        textList.add(new Object[] {"atheism","E:/michael/workspace/yale/plugins/wvtool/sample/data/alt.atheism"});
        textList.add(new Object[] {"religion","E:/michael/workspace/yale/plugins/wvtool/sample/data/soc.religion.christian"});
        
        wvtoolOperator.setListParameter("texts", textList);
        
        IOContainer out = wvtoolOperator.apply(new IOContainer());
//        ExampleSet es = (ExampleSet) out.get(ExampleSet.class);
        
        out = clusterer.apply(out);
        
        HierarchicalClusterModel hcm = (HierarchicalClusterModel) out.get(HierarchicalClusterModel.class);
        System.out.println(hcm);
    }

}
